﻿using System;
using System.Collections.Generic;
using Character;
using UnityEngine;

// Token: 0x02000145 RID: 325
internal class HairObj
{
	// Token: 0x060007D9 RID: 2009 RVA: 0x0002EE0C File Offset: 0x0002D00C
	public HairObj(GameObject obj, Transform hirsParent)
	{
		this.obj = obj;
		this.SetParent(hirsParent);
		this.SetupMaterial();
		this.hasAcce = (this.acceMaterials.Count > 0);
	}

	// Token: 0x170000E7 RID: 231
	// (get) Token: 0x060007DA RID: 2010 RVA: 0x0002EE60 File Offset: 0x0002D060
	// (set) Token: 0x060007DB RID: 2011 RVA: 0x0002EE68 File Offset: 0x0002D068
	public bool hasAcce { get; private set; }

	// Token: 0x170000E8 RID: 232
	// (get) Token: 0x060007DC RID: 2012 RVA: 0x0002EE74 File Offset: 0x0002D074
	public DynamicBone[] dynamicBone
	{
		get
		{
			return this.obj.GetComponentsInChildren<DynamicBone>();
		}
	}

	// Token: 0x060007DD RID: 2013 RVA: 0x0002EE84 File Offset: 0x0002D084
	private void SetupMaterial()
	{
		Renderer[] componentsInChildren = this.obj.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer renderer in componentsInChildren)
		{
			if (renderer.tag == "ObjHair")
			{
				foreach (Material item in renderer.materials)
				{
					this.hairMaterials.Add(item);
				}
			}
			else if (renderer.tag == "ObjHairAcs")
			{
				foreach (Material item2 in renderer.materials)
				{
					this.acceMaterials.Add(item2);
				}
			}
		}
	}

	// Token: 0x060007DE RID: 2014 RVA: 0x0002EF54 File Offset: 0x0002D154
	public void SetParent(Transform hirsParent)
	{
		this.obj.transform.SetParent(hirsParent, false);
		this.obj.transform.localScale = Vector3.one;
		this.obj.transform.localRotation = Quaternion.identity;
		this.obj.transform.localPosition = Vector3.zero;
	}

	// Token: 0x060007DF RID: 2015 RVA: 0x0002EFB4 File Offset: 0x0002D1B4
	public void ChangeColor(HairPartParameter param)
	{
		for (int i = 0; i < this.hairMaterials.Count; i++)
		{
			param.hairColor.SetToMaterial(this.hairMaterials[i]);
		}
		if (this.hasAcce)
		{
			if (param.acceColor == null)
			{
				param.acceColor = new ColorParameter_PBR1(this.acceMaterials[0]);
			}
			else
			{
				for (int j = 0; j < this.acceMaterials.Count; j++)
				{
					param.acceColor.SetToMaterial(this.acceMaterials[j]);
				}
			}
		}
		else
		{
			param.acceColor = null;
		}
	}

	// Token: 0x040007B4 RID: 1972
	public GameObject obj;

	// Token: 0x040007B6 RID: 1974
	private List<Material> hairMaterials = new List<Material>();

	// Token: 0x040007B7 RID: 1975
	private List<Material> acceMaterials = new List<Material>();
}
